package com.linkhub.oms.admin.modules.stock.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.linkhub.oms.admin.modules.satoken.session.LhSessionContext;
import com.linkhub.oms.admin.modules.stock.domain.param.OutStockQueryParam;
import com.linkhub.oms.admin.modules.stock.domain.param.StockFlowQueryParam;
import com.linkhub.oms.admin.modules.stock.domain.vo.OutStockVO;
import com.linkhub.oms.admin.modules.stock.domain.vo.StockFlowVO;
import com.linkhub.oms.admin.modules.stock.service.OutStockBizService;
import com.linkhub.oms.common.enums.mp.RoleCodeEnum;
import com.linkhub.oms.common.response.DataResponse;
import com.linkhub.oms.common.response.PageDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName OutStockController
 * @Description TODO
 * @Author XieYu
 * @Date 2024/7/1 23:24
 * @Version 1.0
 */
@Slf4j
@RestController
@Api(tags = {"本地商品库存管理模块"})
@RequestMapping("/outstock")
@SaCheckLogin
public class OutStockController {
    @Resource
    private OutStockBizService outStockBizService;

    @GetMapping("/list")
    @ApiOperation(value = "查询缺货列表")
    public DataResponse<PageDTO<OutStockVO>> physicalStocks(@Validated OutStockQueryParam outStockQueryParam) {
        List<String> userRoles = LhSessionContext.getUserRoles();
        outStockQueryParam.setCustomerRole(userRoles.contains(RoleCodeEnum.CUSTOMER.getCode()));
        return DataResponse.success(outStockBizService.list(outStockQueryParam));
    }
}
